#pragma once
#include <condition_variable>
#include <memory>
#include <mutex>
#include <thread>

class EventLoop;

/// 封装“线程 + EventLoop”组合
class EventLoopThread {
public:
    EventLoopThread();
    ~EventLoopThread();

    EventLoop& startLoop();  // 创建线程并返回其 EventLoop

private:
    void threadFunc();

    EventLoop* loop_{nullptr};
    std::thread thread_;
    std::mutex mutex_;
    std::condition_variable cond_;
    bool exiting_{false};
};